package com.cpr.ams.service.impl;

import com.cpr.ams.bean.PayService;
import com.cpr.ams.bean.extend.OrderExtend;
import com.cpr.ams.bean.extend.RoomExtend;
import com.cpr.ams.mapper.PayServiceMapper;
import com.cpr.ams.mapper.extend.CheckExtendMapper;
import com.cpr.ams.service.ICheckInService;
import com.jacky.base.utils.PageVM;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CheckInServiceImpl implements ICheckInService {
    @Autowired
    private PayServiceMapper orderMapper;
    @Autowired
    private CheckExtendMapper checkExtendMapper;
    @Override
    public void saveOrUpdateCheck(PayService order) {
        if (order.getId()!=null){
            orderMapper.updateByPrimaryKeySelective(order);
        }else {
            orderMapper.insert(order);
        }
    }

    @Override
    public PageVM<OrderExtend> query(Integer page, Integer pageSize, Integer userId) {
        List<OrderExtend> list=checkExtendMapper.query(page,pageSize,userId);
        long total =checkExtendMapper.count(userId);
        return new PageVM<>(page, pageSize, total, list);
    }

    @Override
    public OrderExtend queryById(int id) {
        return checkExtendMapper.queryById(id);
    }

}
